﻿using System;
using System.Collections.Generic;

namespace AzukiMap.MapSource
{
    /// <summary>
    /// 4 crossEx
    /// </summary>
    public class GsiSourceProxy : GsiSource
    {
        private const string PROXY_BASE_DEFAULT = "/map/am/proxy_gsi.php?u=";
        private const string LOGO = "/denshiKokudoLogo.png";

        private string _proxyBase = PROXY_BASE_DEFAULT;

        public string ProxyBase
        {
            get { return _proxyBase; }
            set
            {
                _proxyBase = value;
                SetScaleAndUri();
            }
        }

        protected override void SetScaleAndUri()
        {
            BaseUris = new Dictionary<double, string>();
            Scales = new List<double>();
            GeoScales = new Dictionary<double, double>();
            TileScalesRev = new Dictionary<double, double>();
            TileWidth = new Dictionary<double, int>();

            SetScaleAndUriCore(15, GSI_DEFAULT_TILEWIDTH, string.Format("{0}/15/new/", ProxyBase));
            SetScaleAndUriCore(30, GSI_DEFAULT_TILEWIDTH, string.Format("{0}/30/new/", ProxyBase));
            SetScaleAndUriCore(60, GSI_DEFAULT_TILEWIDTH, string.Format("{0}/60/new/", ProxyBase));
            SetScaleAndUriCore(120, GSI_DEFAULT_TILEWIDTH, string.Format("{0}/120/new/", ProxyBase));
            SetScaleAndUriCore(240, GSI_DEFAULT_TILEWIDTH, string.Format("{0}/240/new/", ProxyBase));
            SetScaleAndUriCore(480, GSI_DEFAULT_TILEWIDTH, string.Format("{0}/480/new/", ProxyBase));
            SetScaleAndUriCore(960, GSI_DEFAULT_TILEWIDTH, string.Format("{0}/960/new/", ProxyBase));
            SetScaleAndUriCore(1920, GSI_DEFAULT_TILEWIDTH, string.Format("{0}/1920/new/", ProxyBase));
            SetScaleAndUriCore(3840, GSI_DEFAULT_TILEWIDTH, string.Format("{0}/3840/new/", ProxyBase));
            SetScaleAndUriCore(7680, GSI_DEFAULT_TILEWIDTH, string.Format("{0}/7680/new/", ProxyBase));
            SetScaleAndUriCore(15360, GSI_DEFAULT_TILEWIDTH, string.Format("{0}/15360/new/", ProxyBase));
            SetScaleAndUriCore(30720, GSI_DEFAULT_TILEWIDTH, string.Format("{0}/30720/new/", ProxyBase));
        }

        protected override void SetSourceLogo()
        {
            SourceLogo = new Uri(LOGO, UriKind.RelativeOrAbsolute);
        }
    }
}